package string

// https://leetcode-cn.com/leetbook/read/top-interview-questions-easy/xn96us/
// 是否字母异位词
// 只要字母出现的次数相同即可
func isAnagram(s string, t string) bool {
	if len(s) != len(t) {
		return false
	}
	occurMap := make(map[int32]int, 0)
	for _, currentChar := range s {
		occurMap[currentChar]++
	}
	for _, currentChar := range t {
		switch occurMap[currentChar] {
		case 0:
			return false
		case 1:
			delete(occurMap, currentChar)
		default:
			occurMap[currentChar]--
		}
	}
	// 可以走到这里，就说明一定满足要求了
	return true
}
